/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.cesupa.cabcc.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;

/**
 *
 * @author yuri
 */
@Entity
@NamedQueries({
    @NamedQuery(name="Bolsista.findById", query="SELECT b FROM Bolsista b Where b.id = :id"),
    @NamedQuery(name="Bolsista.findByData", query="SELECT b FROM Bolsista b Where b.dataBolsa = :dataBolsa"),
    @NamedQuery(name="Bolsista.findByUsuario", query="SELECT b FROM Bolsista b JOIN b.usuarios AS u Where u = :usuario"),
    @NamedQuery(name="Bolsista.findAll", query="SELECT b FROM Bolsista b")
})
public class Bolsista implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dataBolsa;
    @OneToMany
    private List<Usuario> usuarios;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Bolsista)) {
            return false;
        }
        Bolsista other = (Bolsista) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.cesupa.cabcc.entity.Bolsista[id=" + id + "]";
    }

    /**
     * @return the dataBolsa
     */
    public Date getDataBolsa() {
        return dataBolsa;
    }

    /**
     * @param dataBolsa the dataBolsa to set
     */
    public void setDataBolsa(Date dataBolsa) {
        this.dataBolsa = dataBolsa;
    }

    /**
     * @return the usuarios
     */
    public List<Usuario> getUsuarios() {
        return usuarios;
    }

    /**
     * @param usuarios the usuarios to set
     */
    public void setUsuarios(List<Usuario> usuarios) {
        this.usuarios = usuarios;
    }

}
